Hashing Graphs Trees Search Trees Indexing and Multiway Trees File Organization

Introduction

Graph ADT

Data Structure of Graph

Implementation of Graph

Graph traversals

Directed Graph

Planarity

Shortest path Dijkstra’s algorithm

Shortest paths Floyd's algorithm

Minimal Spanning Trees

Travelling salesman and Vehicle Routing

Imagine you have a sheet of paper, and you want to draw some lines (representing edges) and dots (representing vertices) on it in such a way that no lines cross each other. This is what a planar graph is all about.

For example, think of a scenario where you have a group of friends and you want to draw a map to show who is friends with whom. Each friend is a dot, and if two friends are connected, you draw a line between them. But here's the catch: you want to draw it in such a way that no lines cross each other.

Now, let's imagine we have a group of friends: Alice, Bob, Carol, and Dave. If everyone is friends with everyone else, it's like a small community where everyone knows everyone. In graph terms, this is called the complete graph \( K_4 \). It looks like this:


   A
  / \
 /   \
B --- C
 \   /
  \ /
   D

You can draw it without any lines crossing.

Now, let's consider a bigger group. We add another friend, Eve, to the mix. Now we have \( K_5 \), where everyone is friends with everyone else:


   A
  /|\
 / | \
B--|--C
 \ | /
  \|/
   D

If you try to draw this on a flat surface (like a piece of paper), you'll see that it's impossible to draw without some lines crossing. This means (K5) is not planar.

Similarly, let's consider a different scenario. Imagine you have three groups of friends: Alice, Bob, and Carol are all friends with each other, and Dave, Eve, and Frank are also all friends with each other. But there's no connection between the two groups. This forms what's called the bipartite graph (K3,3):


   A
  / \
 /   \
B --- C
 |   |
 D   E
  \ /
   F

Again, if you try to draw this without any lines crossing, it's not possible. So, (K3,3) is also not planar.


Now, here's where it gets interesting. There are some theorems that help us determine if a graph is planar or not. Kuratowski’s theorem tells us that if a graph contains a ( K5) or (K3,3) subgraph, it's not planar. And Wagner’s theorem says the same thing, but instead of subgraph, it talks about minors.

So, if we want to test if a graph is planar, we can look for these forbidden subgraphs or minors. If we find any, the graph is not planar. Otherwise, it might be planar.

There are algorithms that help us do this efficiently, even for large graphs with lots of vertices. These algorithms use clever techniques to search for these forbidden structures and determine if the graph can be drawn without any lines crossing. And that's the essence of testing for planarity!

Graph ADT


The Graph Abstract Data Type (ADT) is like a social network, where vertices represent people and edges represent friendships. It organizes connections between entities, offering operations to add/remove vertices and edges, and access their properties. Think of it as a digital framework for understanding and managing relationships.


Nodes in Graph


Nodes, often called vertices, are the building blocks of a graph, resembling points or entities. They represent objects such as cities, people, or devices in a network. Each node holds unique information and can be connected to other nodes through edges. Think of nodes as the key players in a network, like characters in a story or landmarks on a map. Their connections form the backbone of relationships and interactions, making them essential for understanding and analyzing complex systems.


vertex in graph


In a graph, a vertex (or node) represents an object or entity. It's depicted as a point or shape, like a circle or rectangle. Vertices are connected by edges, indicating relationships between them. In a transportation network, vertices can represent cities, while in a social network, they represent individuals.